export interface User {
  username: string;
  password: string;
  registerTime?: string;
  email?: string;
}

let currentUser: User | null = null;

export function getUserInfo(): User | null {
  return currentUser;
}

export function setUserInfo(user: User): void {
  currentUser = user;
}

export function updatePassword(newPassword: string): void {
  if (currentUser) {
    currentUser.password = newPassword;
  }
}

export function login(username: string, password: string): boolean {
  // 实际应用中应该有更复杂的验证逻辑
  if (username === currentUser?.username && password === currentUser?.password) {
    return true;
  }
  return false;
}

export function logout(): void {
  currentUser = null;
}